﻿#include <osgViewer/Viewer>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/api/Win32/GraphicsWindowWin32>
#include <osg/GraphicsContext>

#include <iostream>
int main()
{
	osgViewer::Viewer viewer;  // 让osgViewer参与编译，createGraphicsContext才会有值。
	osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
	traits->x = 100;
	traits->y = 100;
	traits->width = 200;
	traits->height = 200;
	traits->windowDecoration = true;
	traits->doubleBuffer = true;
	traits->sharedContext = 0;
	traits->pbuffer = false;  // 是否为离屏渲染

	osgViewer::GraphicsWindowWin32 * gw = (osgViewer::GraphicsWindowWin32 *)osg::GraphicsContext::createGraphicsContext(traits.get());
	
	if (gw == nullptr)
	{
		std::cout << "gw is null." << std::endl;
	}

	gw->realizeImplementation(); // 创建窗口 (没有消息循环，窗口卡死)
	int a;
	std::cin >> a;

	return 0;
}